﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GameCode.Models.Admin
{
    [Serializable]
    public class BaseModel
    {
        public bool IsReturn { get; set; }
        public string NewLink { get; set; }
        public List<Menu> MenuList { get; set; }
        public string Caption { get; set; }
        public Menu GetSelectMenu()
        {
            foreach (var menu in MenuList)
            {
                if (menu.IsSelect)
                    return menu;
            }
            return null;
        }

        public BaseModel()
        {
            MenuList = new List<Menu>() 
            {
                 new Menu(){ Title = "游戏管理" , Key = "" , SubList = new List<Menu>()
                {
                    new Menu(){ Title = "游戏类型" , Key = "/Admin/GameType"},
                    new Menu(){ Title = "游戏项目" , Key = "/Admin/GameProject"},
                    new Menu(){ Title = "游戏推荐" , Key = "/Admin/GameRecommend"},
                    new Menu(){ Title = "特权码" , Key = "/Admin/GameCode"},
                    new Menu(){ Title = "广告管理" , Key = "/Admin/Advertise"},
                    new Menu(){ Title = "新区资信管理" , Key = "/Admin/NewArea"},
                    new Menu(){ Title = "消息管理" , Key = "/Admin/News"},
                    //new Menu(){ Title = "推送管理" , Key = "/Admin/Push"},
                }},
                new Menu(){ Title = "统计分析" , Key = "", SubList = new List<Menu>()
                {
                    new Menu(){ Title = "设备统计" , Key = "/Admin/DeviceReport"},
                    new Menu(){ Title = "项目统计" , Key = "/Admin/ProjectReport"},
                    new Menu(){ Title = "广告统计" , Key = "/Admin/AdvertiseReport"},
                    new Menu(){ Title = "综合统计" , Key = "/Admin/AdvancedReport"},
                    
                }},
                new Menu(){ Title = "主页管理" , Key = "", SubList = new List<Menu>()
                {
                    new Menu(){ Title = "滚动图管理" , Key = "/Admin/Banner"},
                    new Menu(){ Title = "页面设置" , Key = "/Admin/PageSetting"},
                    new Menu(){ Title = "友情链接管理" , Key = "/Admin/FriendLink"},
                    new Menu(){ Title = "产品页文章" , Key = "/Admin/Article?type=Product"},
                    new Menu(){ Title = "下载页文章" , Key = "/Admin/Article?type=Download"},
                    new Menu(){ Title = "商务合作页文章" , Key = "/Admin/Article?type=Teamwork"},
                    new Menu(){ Title = "手机浏览页文章" , Key = "/Admin/Article?type=Mobile"},
                    
                }},
                new Menu(){ Title = "其他" , Key = "", SubList = new List<Menu>()
                {
                    new Menu(){ Title = "数据库备份" , Key = "/Admin/Backup"},
                    new Menu(){ Title = "数据库还原" , Key = "/Admin/Restore"},
                    new Menu(){ Title = "其他设置" , Key = "/Admin/Password"},
                    new Menu(){ Title = "安卓应用管理" , Key = "/Admin/AndroidApp"},
                }}};
        }

        public void Select(string title)
        {
            foreach (var menu in MenuList)
            {
                menu.IsSelect = false;
                if (menu.Title == title)
                {
                    menu.IsSelect = true;
                    foreach (var subMenu in menu.SubList)
                    {
                        subMenu.IsSelect = false;
                    }
                }
                else
                {
                    foreach (var subMenu in menu.SubList)
                    {
                        subMenu.IsSelect = false;
                        if (subMenu.Title == title)
                        {
                            subMenu.IsSelect = true;
                            menu.IsSelect = true;
                        }
                    }
                }
            }
        }
    }
}